<script setup>
import HomePanel  from '@/views/Home/components/HomePanel.vue';

import { onMounted, ref } from "vue";
import { getProductListAPI } from '@/apis/homeAPI'

const productList = ref([]);
const getProductList = async () =>{
      //业务逻辑

      //调用接口
      const res = await getProductListAPI({ isRecommend: 1 });
      productList.value = res.data;
}

onMounted(() => {
    getProductList();
});
</script>
<template>

<HomePanel title="掌柜推荐" subTitle="人气爆款 不容错过">
<template #main>
     <!-- 下面是插槽主体内容模版  -->
      <ul class="goods-list">
        <li v-for="item in productList" :key="item.id">
          <RouterLink :to="`/detail/${item.id}`">
            <img v-img-lazy="item.pic"  alt="">
            <p class="name">{{item.productName}}</p>
            <p class="price"><i>¥</i>{{item.price}}</p>
          </RouterLink>
        </li>
      </ul>
</template>
</HomePanel>
</template>
<style scoped lang="scss">
.goods-list {
    display: flex;
    justify-content: space-between;
    height: 406px;

    li {
      width: 306px;
      height: 406px;

      background: #f0f9f4;
      transition: all .5s;

      &:hover {
        transform: translate3d(0, -3px, 0);
        box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
      }

      img {
        width: 306px;
        height: 306px;
          margin-left: -3px;
      }

      p {
        font-size: 22px;
        padding-top: 6px;
        text-align: center;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }

      .des{
        font-size: 12px;
      }

      .price {
        color: $priceColor;
      }
    }
  }
</style>
